package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FlightOrderAssist;
import com.ktgj.flight.service.IFlightOrderAssistService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 机票订单辅营产品Controller
 * 
 * @author ruoyi
 * @date 2022-04-28
 */
@RestController
@RequestMapping("/assist")
public class FlightOrderAssistController extends BaseController
{
    @Autowired
    private IFlightOrderAssistService flightOrderAssistService;

    /**
     * 查询机票订单辅营产品列表
     */
    @PreAuthorize(hasPermi = "flight:assist:list")
    @GetMapping("/list")
    public TableDataInfo list(FlightOrderAssist flightOrderAssist)
    {
        startPage();
        List<FlightOrderAssist> list = flightOrderAssistService.selectFlightOrderAssistList(flightOrderAssist);
        return getDataTable(list);
    }

    /**
     * 导出机票订单辅营产品列表
     */
    @PreAuthorize(hasPermi = "flight:assist:export")
    @Log(title = "机票订单辅营产品", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlightOrderAssist flightOrderAssist) throws IOException
    {
        List<FlightOrderAssist> list = flightOrderAssistService.selectFlightOrderAssistList(flightOrderAssist);
        ExcelUtil<FlightOrderAssist> util = new ExcelUtil<FlightOrderAssist>(FlightOrderAssist.class);
        util.exportExcel(response, list, "机票订单辅营产品数据");
    }

    /**
     * 获取机票订单辅营产品详细信息
     */
    @PreAuthorize(hasPermi = "flight:assist:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(flightOrderAssistService.selectFlightOrderAssistById(id));
    }

    /**
     * 新增机票订单辅营产品
     */
    @PreAuthorize(hasPermi = "flight:assist:add")
    @Log(title = "机票订单辅营产品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlightOrderAssist flightOrderAssist)
    {
        return toAjax(flightOrderAssistService.insertFlightOrderAssist(flightOrderAssist));
    }

    /**
     * 修改机票订单辅营产品
     */
    @PreAuthorize(hasPermi = "flight:assist:edit")
    @Log(title = "机票订单辅营产品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlightOrderAssist flightOrderAssist)
    {
        return toAjax(flightOrderAssistService.updateFlightOrderAssist(flightOrderAssist));
    }

    /**
     * 删除机票订单辅营产品
     */
    @PreAuthorize(hasPermi = "flight:assist:remove")
    @Log(title = "机票订单辅营产品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(flightOrderAssistService.deleteFlightOrderAssistByIds(ids));
    }
}
